$(function(){

    $(function(){
        setProduckTitle();
        getproduct();
        getproductcom();
    })

     /*获取url中的参数*/
    function getQueryString(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        //console.log(r);
        if (r != null) {
            return decodeURI(r[2]);
        }
        return null;
    }

    function setProduckTitle() {

        var brandName = getQueryString('brandName');
        //console.log(title);
        //title = decodeURI(title);
        $('#bijia>.product-title>.breadcrumb>li.active').html(brandName);
    }

    function getproduct(){
        /*获取url中的参数*/
        var productid = getQueryString('productid');
       // console.log(productid);
        $.get('http://139.199.157.195:9090/api/getproduct?productid='+productid,function(result){

            var html = template('titleTpl',result);
            var tabHtml = template('tableTpl',result);
           // console.log(html);
            $('#bijia>.bijia-info>.bijia-title').html(html);
            $('#bijia>.bijia-info>.bijia-table').html(tabHtml);
            
        })

    }

    function getproductcom(){

        var productid = getQueryString('productid');
        
        $.get('http://139.199.157.195:9090/api/getproductcom?productid='+productid,function(result){
            //console.log(result);
            var html = template('evaTpl',result);
           // console.log(html);
            $('#bijia>.bijia-info>.bijia-eva ul').html(html);
            
        })
    }


})